<template>
  <ul class="todo-list">
    <li :class="{ completed: item.isDone }" v-for="item in list" :key="item.id">
      <div class="view">
        <input class="toggle" type="checkbox" v-model="item.isDone" />
        <label>{{ item.name }}</label>
        <button class="destroy" @click="delFn(item.id)"></button>
      </div>
    </li>
  </ul>
</template>

<script>
export default {
  props: ["list"],
  methods: {
    delFn(id) {
      // 将 id 传递给 App.vue 由爸爸来删除
      this.$emit("delTask", id);
    },
  },
};
</script>